local mibei = fk.CreateSkill{
    name = "ym1__mibei",
}
Fk:loadTranslationTable{
    ["ym1__mibei"] = "秘备",
    [":ym1__mibei"] = "准备阶段，若你的手牌不为全场最多，你可视为使用<a href='ym1__mibei-adaptation'>卜算两张手牌的【洞烛先机】</a>。",
    ["ym1__mibei-adaptation"] = "其实就是卜算两张手牌再摸两张牌。<br><b>卜算两张手牌</b>：将两张手牌任意置于牌堆两端",
    ["#ym1__mibei-choose"] = "秘备：选择要卜算的两张手牌",

    ["$ym1__mibei1"] = "密为之备，不可有失。",
    ["$ym1__mibei2"] = "事以密成，语以泄败！",
}
mibei:addEffect(fk.EventPhaseStart,{
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(mibei.name) and player.phase == Player.Start and player:getHandcardNum() >= 2 and
        not table.every(player.room.alive_players, function(p) return player:getHandcardNum() >= p:getHandcardNum() end)
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:useVirtualCard("ym__foresight", nil, player, {player}, mibei.name)
    end,
})
mibei:addEffect(fk.PreCardEffect,{
    can_refresh = function(self, event, target, player, data)
        return data.from == player and data.card.name == "ym__foresight" and table.contains(data.card.skillNames, mibei.name)
    end,
    on_refresh = function(self, event, target, player, data)
        local card = data.card:clone()
        local c = table.simpleClone(data.card)
        for k, v in pairs(c) do
            card[k] = v
        end
        card.skill = Fk.skills["ym1__mibei_foresight_skill"]
        data.card = card
    end,
})

return mibei